package group.rober.rax.devkit.controller;

import group.rober.rax.devkit.entity.ObjectWindow;
import group.rober.rax.devkit.entity.ObjectWindowCode;
import group.rober.rax.devkit.entity.ObjectWindowItem;
import group.rober.rax.devkit.service.ObjectWindowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "OW开发工具服务", description = "OW开发工具服务")
@RestController
@RequestMapping("/ow")
public class ObjectWindowController {
    @Autowired
    protected ObjectWindowService objectWindowService;

    @ApiOperation(value = "列出分类目录")
    @GetMapping("/catalogs")
    public List<ObjectWindowCode> getCatalogContent() {
        return objectWindowService.getCatalog();
    }

    @ApiOperation(value = "列出所有显示模板")
    @GetMapping("/list")
    public List<ObjectWindow> getObjectWindows() {
        return objectWindowService.getObjectWindows();
    }

    @ApiOperation(value = "分类显示模版")
    @GetMapping("/catalogList")
    public List<ObjectWindow> getCatalogList(@RequestParam("doType") String doType) {
        return objectWindowService.getCatalogList(doType);
    }

    @ApiOperation(value = "使用关键字搜索显示模板")
    @GetMapping("/search")
    public List<ObjectWindow> searchObjectWindows(@RequestParam("keyWord") String keyWord) {
        return objectWindowService.searchObjectWindows(keyWord);
    }

    @ApiOperation(value = "保存显示模板")
    @GetMapping("/save")
    public int saveObjectWindow(ObjectWindow objectWindow) {
        return objectWindowService.saveObjectWindow(objectWindow);
    }
}
